package club.kingyin.easycache.component.annotation.handler;

import club.kingyin.easycache.key.AbstractEasyCacheKey;
import club.kingyin.easycache.component.InjectPostProcess;
import club.kingyin.easycache.component.Pram;
import club.kingyin.easycache.component.annotation.Ignore;
import lombok.extern.slf4j.Slf4j;

import java.lang.annotation.Annotation;
@Slf4j
public class AnnotationIgnoreFieldPostProcess implements InjectPostProcess {
    @Override
    public void postProcessBeforeInject(Annotation[] annotation, AbstractEasyCacheKey key, Pram pram) {

    }

    @Override
    public boolean postProcessPreInject(boolean pre, Annotation[] annotation, AbstractEasyCacheKey key,Pram pram) {
        for (Annotation ignore : annotation) {
            if (ignore.annotationType().equals(Ignore.class)) {
                log.debug("模块：[{}] 方法：[{}] 参数排除 {}", key.getModule(), key.getMethodName(), pram.getPramName());
                key.excludes.add(pram.getPramName());
            }
        }
        return pre;
    }

    @Override
    public void postProcessAfterInject(boolean isInject, Annotation[] annotation, AbstractEasyCacheKey key,String paramName, Object param) {

    }
}
